﻿using SHKF.B2C.Mannage.AdminUI.View.WorkingCenter;
using SHKF.B2C.Model.Dto.WorkingCenter;
using SHKF.B2C.Model.Entity.WorkingCenter;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SHKF.B2C.Mannage.AdminUI.View.CenterInfo.Shop
{
    /// <summary>
    /// frmShopRelatedEdit.xaml 的交互逻辑
    /// </summary>
    public partial class frmShopRelatedEdit : Window
    {
        public frmShopRelatedEdit()
        {
            InitializeComponent();
        }
 
        private async void btnSave_Click(object sender, RoutedEventArgs e)
        { 
            ShopRelatedEntity info = (ShopRelatedEntity)this.DataContext; 
            if( info.WarehousSN == "")
            {
                MessageBox.Show("请选择分仓");
                return;
            } 

            ShopRelatedDto dto = await GL.HttpClientManage.SaveShopRelated(info);
            if (dto.error == null)
            {
                MessageBox.Show("保存成功!");
                this.DataContext = dto.data;
                this.DialogResult = true;
                this.Close();
            }
            else
            {
                MessageBox.Show(dto.error.msg);
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
  
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            
        }
 
        private void btnSelectDataWarehous_Click(object sender, RoutedEventArgs e)
        {
            frmSearchDataWarehous win = new frmSearchDataWarehous();
            if(win.ShowDialog() == true)
            {
                DataWarehousInfoEntity selected = win.Data;

                ShopRelatedEntity info = (ShopRelatedEntity)this.DataContext;
                info.ServerName = selected.ServerName;
                info.WarehousName = selected.WarehousName;
                info.WarehousSN = selected.WarehousSN;
            }
           
        }
    }
}
